<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://expath.org/mod/expath-pkg/modules"
                xmlns:mod="http://expath.org/mod/expath-pkg/modules"
                exclude-result-prefixes="mod"
                version="1.0">

   <xsl:output indent="yes"/>

   <xsl:param name="name"    select="/.."/>
   <xsl:param name="version" select="/.."/>
   <xsl:param name="title"   select="/.."/>
   <xsl:param name="dir"     select="/.."/>

   <xsl:template match="node()">
      <xsl:copy>
         <xsl:copy-of select="@*"/>
         <xsl:apply-templates/>
      </xsl:copy>
   </xsl:template>

   <xsl:template match="mod:module[@dir = $dir]"/>

   <xsl:template match="mod:modules">
      <xsl:copy>
         <xsl:copy-of select="@*"/>
         <xsl:apply-templates/>
         <module version="{ $version }" name="{ $name }" dir="{ $dir }">
            <title>
               <xsl:value-of select="$title"/>
            </title>
         </module>
      </xsl:copy>
   </xsl:template>

</xsl:stylesheet>
